package com.persondemo.videoappliction.ui.adapter;
import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.RatingBar;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lzy.ninegrid.ImageInfo;
import com.lzy.ninegrid.NineGridView;
import com.lzy.ninegrid.preview.NineGridViewClickAdapter;
import com.persondemo.videoappliction.R;
import com.persondemo.videoappliction.bean.DianPingDetilsBean;
import com.persondemo.videoappliction.utils.ImageLoaderUtil;

import java.util.ArrayList;
import java.util.List;

public class DPdetilsAdapter extends BaseQuickAdapter<DianPingDetilsBean.DataBean.ListBean,BaseViewHolder> {
    private Context context;

    public DPdetilsAdapter( @Nullable List<DianPingDetilsBean.DataBean.ListBean> data, Context context) {
        super(R.layout.item_dianping_detils, data);
        this.context = context;
    }
    @Override
    protected void convert(BaseViewHolder helper, DianPingDetilsBean.DataBean.ListBean item) {
        ImageLoaderUtil.LoadImage(mContext, item.getUseravter(), (ImageView) helper.getView(R.id.item_dianping_detils_img));
         helper.setText(R.id.item_dianping_detils_name,item.getUsername());
        RatingBar rb=helper.getView(R.id.item_dianping_detils_Ratingbar);
        rb.setRating(Float.parseFloat(item.getPing()));
        helper.setText(R.id.item_dianping_detils_comment,item.getContent());
        helper.setText(R.id.item_dianping_detils_time,item.getTime());
        List<ImageInfo> imageInfo=new ArrayList<>();
        if (item.getImgs() != null) {
            for (String imageDetail : item.getImgs()) {
                ImageInfo info = new ImageInfo();
                info.setThumbnailUrl(imageDetail);
                info.setBigImageUrl(imageDetail);
                imageInfo.add(info);
            }
        }
        NineGridView nineGridView=helper.getView(R.id.nineGrid);
        nineGridView.setAdapter(new NineGridViewClickAdapter(context, imageInfo));

    }
}
